
export class AndroidUtil {
    // static className;
    /**
 * 发送消息到安卓
 * @param data object(json格式)
 */
    static postMessageToAndroid (data, className) {
        let str = JSON.stringify(data);
        console.log("[MainScene] postMessageToAndroid:", str);
        // 这个需要是原生android吧
        let result = jsb.reflection.callStaticMethod(className, "revJsMessage", "(Ljava/lang/String;)Ljava/lang/String;", str);
        console.log("[MainScene] postMessageToAndroid: result: ", result);
        // let result = jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "revJsMessage", "(Ljava/lang/String;)Ljava/lang/String;", str);
    }

    static getUserCmd=1;

    /**
     * 接收来自安卓的原生消息
     * @param data json格式字符串
     */
    static revAndroidMsg (data) {
        let json = JSON.parse(data);
        let cmd = json.cmd;
        switch (cmd) {
            // case 1001:
           case getUserCmd:
                console.log("[MainScene] revAndroidMsg:", cmd, json.msg);
                break;
        }
    }

}
